<template>
	<view class="pad-30">
		<view v-for="(item,index) in list" class="mar-bottom-40">
			<view class="title mar-top-30">{{item.title}}</view>
			<view class="mar-top-30">所属项目： {{item.cate_title}}</view>
			<view class="button-box centerXY mar-top-20">
				<up-button @click="hanldeStart(item.id)" shape="circle" class="mar-right-20" type="error"
					text="开始测试"></up-button>
				<up-button shape="circle" class="mar-right-20" type="info" :text="'错题数： ' + item.number"></up-button>
				<up-button @click="hanldeInfo(item.id)" shape="circle" type="primary" :plain="true"
					text="查看详情"></up-button>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';

	import {
		errorList
	} from '/config/api.js';

	import {
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app'

	// 错题详情
	const hanldeInfo = (id) => {
		uni.navigateTo({
			url: '/pages/wrongInfo/wrongInfo?id=' + id,
		})
	}

	// 开始测试
	const hanldeStart = (id) => {
		uni.navigateTo({
			url: '/pages/wrongTest/wrongTest?id=' + id
		})
	}

	// 获取列表
	let params = reactive({
		page: 1,
		page_size: 15
	})

	// 获取错题集
	let list = ref([])
	const getListInfo = () => {
		errorList(params).then(({
			data
		}) => {
			list.value = list.value.concat(data.data)
		})
	}

	onLoad(() => {
		getListInfo();
	})
</script>

<style scoped lang="scss">
	.title {
		font-weight: bold;
	}
</style>